﻿<!--- ==================================================
NAME:	get_shpntax.cfm
DESC:	File used to get the shipping methods, shiping
		cost and tax amount.
=================================================== --->
<cfsetting enablecfoutputonly="yes">

<!--- default data --->
<cfparam name="arguments.customerid" type="any" default="">
<cfparam name="arguments.source" type="any" default="">
<cfparam name="arguments.code" type="any" default="">
<cfparam name="arguments.price" type="any" default="">
<cfparam name="arguments.city" type="any" default="">
<cfparam name="arguments.state" type="any" default="">
<cfparam name="arguments.zip" type="any" default="">
<cfparam name="arguments.country" type="any" default="">
<cfparam name="arguments.geo_code" type="any" default="">
<cfparam name="arguments.array_parts" type="any" default="">
<cfparam name="arguments.array_systems" type="any" default="">


<!--- build xml statement --->
<cfscript>
cart = "";
subtotal = 0;
// standalone parts
if  (isarray(arguments.array_parts) and arraylen(arguments.array_parts) GT 0) {
	indexcnt = arraylen(arguments.array_parts) + 1;
	for ( i=1; i lt indexcnt ; i=i+1) {
		cart = cart & '
			<line_item>
				<product>
					<product_code>#ucase(arguments.array_parts[i].product)#</product_code>
					<quantity>#ucase(arguments.array_parts[i].quantity)#</quantity>
					<item_price>#ucase(arguments.array_parts[i].price)#</item_price>
					<weight>#application.string_validation.YNFormat(arguments.array_parts[i].weight)#</weight>
					<condition_type>#arguments.array_parts[i].condition_type#</condition_type>
					<item_number>#i#</item_number>
				</product>
			</line_item>';
	}
}
// kit codes or configurations
if  (isarray(arguments.array_systems) and arraylen(arguments.array_systems)) {
	indexcnt1 = arraylen(arguments.array_systems) + 1;
	for (x=1; x lt indexcnt1; x=x+1) {
	cart = cart & '
		<line_item>
			<configuration>
				<quantity>#ucase(arguments.array_systems[x].quantity)#</quantity>
				<baseunit>
					<product_code>#ucase(arguments.array_systems[x].b_product)#</product_code>
					<item_price>#ucase(arguments.array_systems[x].b_price)#</item_price>
					<weight>#application.string_validation.YNFormat(arguments.array_parts[i].b_weight)#</weight>
					<condition_type>#arguments.array_systems[x].condition_type#</condition_type>
					<item_number>#i#</item_number>
				</baseunit>';
	indexcnt2 = arraylen(arguments.array_systems[x].subitem) + 1;
	for (y=1; y lt indexcnt2;  y=y+1) {
		cart = cart & '
				<component>
					<product_code>#ucase(arguments.array_systems[x].subitem[y].product)#</product_code>
					<quantity>#ucase(arguments.array_systems[x].subitem[y].quantity)#</quantity>
					<item_price>#ucase(arguments.array_systems[x].subitem[y].price)#</item_price>
				</component>';
	}
	cart = cart & '
			</configuration>
		</line_item>';
	}
}
// assemble full xml statement

xi_namespace='#trim(application.xi_namespace)#:ORDERS:GetShipmentTax';
/*
	changed for defect 1250
	changed the node <price>#ucase(arguments.price)#</price> by <price></price>
*/

xi_interface='GetShipTax_OB';
xml = '<xtiinput>
	<inputheader>
		<actionset>
			<action>get_shpntax</action>
		</actionset>
	</inputheader>
	<inputdata>
		<system>#variables.system#</system>
		<customerid>#ucase(arguments.customerid)#</customerid>
		<source>#ucase(arguments.source)#</source>
		<shipping_codes>
			<method>
				<code>#ucase(arguments.code)#</code>
				<price></price>
			</method>
		</shipping_codes>
		<shipping_addr>
			<city>#ucase(arguments.city)#</city>
			<state>#ucase(arguments.state)#</state>
			<zip>#ucase(arguments.zip)#</zip>
			<geo_code>#ucase(arguments.geo_code)#</geo_code>
			<country>#ucase(arguments.country)#</country>
		</shipping_addr>
		<shopping_cart>#cart#
		</shopping_cart>
	</inputdata>
</xtiinput>';
</cfscript>